/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cronos.dao;

import cronos.config.Configuration;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Leonardo Oliveira Moreira
 */
public class DAO {

    protected Connection connection = null;
    
    public DAO() throws SQLException {
        try {
            Class.forName(Configuration.DATABASE_DRIVER);
            connection = DriverManager.getConnection(Configuration.DATABASE_URL, Configuration.DATABASE_USERNAME, Configuration.DATABASE_PASSWORD);
            connection.setAutoCommit(false);
        } catch (ClassNotFoundException ex) {
            connection = null;
        }
    }
    
    public void commit() throws SQLException {
        connection.commit();
    }
    
    public void rollback() throws SQLException {
        connection.rollback();
    }

}